#pragma once

#include <cstdint>
#include "Containers/String.h"

struct WHENGINE_API SIPAddress
{
public:   
    static TOptional<SIPAddress> Create(const CString & InIP);

    union IPAddress
    {
        /* data */
        uint8_t IPv4[4];
        uint16_t IPv6[8];
    };
    

    SIPAddress();

    //SIPAddress(const CString & InIP);

    SIPAddress(const IPAddress & InIP, bool bInIsIPv6);



    //create from ipv4, for example: if ip is  127.0.0.1, then InIP1=127, InIP2=0, InIP3=0, InIP4=1
    SIPAddress(uint8_t InIP1, uint8_t InIP2, uint8_t InIP3, uint8_t InIP4);

    //create from ipv6
    SIPAddress(uint16_t InIP1, uint16_t InIP2, uint16_t InIP3, uint16_t InIP4, uint16_t InIP5, uint16_t InIP6, uint16_t InIP7, uint16_t InIP8);

    //assign from string
    SIPAddress & operator=(const CString & InIP);

    bool operator==(const SIPAddress & Other) const;

    bool IsValid() const;

    bool IsIPv6() const;

    CString ToString() const;


    IPAddress IP;

    static SIPAddress LocalHostIPv4;
protected:
    bool bIsIPv6 = false;
};